<?php
/**************************************************
* PluginLotto.com                                 *
* Copyrights (c) 2005-2010. iZAP                  *
* All rights reserved                             *
***************************************************
* @author iZAP Team "<support@izap.in>"
* @link http://www.izap.in/
* @version {version} $Revision: {revision}
* Under this agreement, No one has rights to sell this script further.
* For more information. Contact "Tarun Jangra<tarun@izap.in>"
* For discussion about corresponding plugins, visit http://www.pluginlotto.com/pg/forums/
* Follow us on http://facebook.com/PluginLotto and http://twitter.com/PluginLotto
 */

// defining constant variable
define('GLOBAL_IZAP_POLL_PLUGIN','izap-poll');
define('GLOBAL_IZAP_POLL_ACTION','izap_poll');
define('GLOBAL_IZAP_POLL_PAGEHANDLER','poll');
define('GLOBAL_IZAP_POLL_SUBTYPE','izapPoll');

function izap_poll_init() {
  if(is_plugin_enabled('izap-elgg-bridge')) {
    izap_plugin_init(GLOBAL_IZAP_POLL_PLUGIN);
  }else {
    register_error('This Plugin Needs Izap-Elgg-Bridge Plugin');
    disable_plugin(GLOBAL_IZAP_POLL_PLUGIN);
  }

// extend the views
  if(is_callable('elgg_extend_view')) {
    $extend_view = 'elgg_extend_view';
  }else {
    $extend_view = 'extend_view';
  }
  $extend_view('index/righthandside', GLOBAL_IZAP_POLL_PLUGIN.'/mainPagePoll');
}

function canUserPostPoll() {
  $admin_setting = get_plugin_setting('allow_user_to_add_poll', GLOBAL_IZAP_POLL_PLUGIN);

  if($admin_setting == 'yes') {
    return TRUE;
  }

  return FALSE;
}

register_elgg_event_handler('init','system','izap_poll_init');